#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;

  vector<vector<int>> shelf(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
    cin >> shelf[i][0] >> shelf[i][1] >> shelf[i][2];
  }

  // dp[i][a][b][c] 改为 dp[a][b][c]
  // a=蛋糕，b=甜甜圈，c=羊角面包
  vector<vector<vector<int>>> dp(
      2, vector<vector<int>>(2, vector<int>(2, INT_MAX)));

  // 初始化第一个货架
  int total = shelf[0][0] + shelf[0][1] + shelf[0][2];
  dp[1][0][0] = total - shelf[0][0]; // 选择蛋糕
  dp[0][1][0] = total - shelf[0][1]; // 选择甜甜圈
  dp[0][0][1] = total - shelf[0][2]; // 选择羊角面包

  for (int i = 1; i < n; i++) {
    total = shelf[i][0] + shelf[i][1] + shelf[i][2];
    vector<vector<vector<int>>> new_dp(
        2, vector<vector<int>>(2, vector<int>(2, INT_MAX)));

    for (int a = 0; a < 2; a++) {
      for (int b = 0; b < 2; b++) {
        for (int c = 0; c < 2; c++) {
          if (dp[a][b][c] == INT_MAX)
            continue;

          // 选择蛋糕
          new_dp[1][b][c] =
              min(new_dp[1][b][c], dp[a][b][c] + (total - shelf[i][0]));

          // 选择甜甜圈
          new_dp[a][1][c] =
              min(new_dp[a][1][c], dp[a][b][c] + (total - shelf[i][1]));

          // 选择羊角面包
          new_dp[a][b][1] =
              min(new_dp[a][b][1], dp[a][b][c] + (total - shelf[i][2]));
        }
      }
    }
    dp = new_dp;
  }

  // 确保三种面包都至少有一个货架
  int result = dp[1][1][1];
  cout << result << endl;
  return 0;
}